
<?php
	require_once("connect_sql.php");
	
	$author = $_GET['author'];
	$board = $_GET['board'];
	$customer = $_GET['customer'];
	$business = $_GET['business'];
	$platform = $_GET['platform'];
	$function = $_GET['function'];
	$lcd = $_GET['lcd'];
	$camera = $_GET['camera'];
	$rfpa = $_GET['rfpa'];
	$classK = $_GET['classK'];
	$lastVersion = $_GET['lastVersion'];
	$lastDate = $_GET['lastDate'];
	//$gbVersion = $_GET['gbVersion'];
	$ataVersion = $_GET['ataVersion'];

	$sql = 'select id from project where board="'.$board.'" and customer="'.$customer.'" and business="'.$business.'"';
	$result = mysql_query($sql);
	if(!$result) echo mysql_error();
	if(mysql_num_rows($result) > 0) {
		echo 'exist';
	} else {
	//TODO add other data
		$sql = "insert into project (author, board, customer, business, platform, function, lcd, camera, rfpa, classK, lastVersion, lastDate, ataVersion) values($author, \"$board\", $customer, \"$business\", $platform, \"$function\", \"$lcd\", \"$camera\", $rfpa, $classK, \"$lastVersion\", \"$lastDate\", \"$ataVersion\")";
		if(!mysql_query($sql)) {
			echo "";
		} else {
			echo "successed";
			
			$str = '新项目(';
			if($ret = mysql_query('select name from author where id='.$author)) {
				$row = mysql_fetch_array($ret);
				$str .= $row['name'].', ';
			}
			$str .= $board.', ';
			if($ret = mysql_query('select name from customer where id='.$customer)) {
				$row = mysql_fetch_array($ret);
				$str .= $row['name'].', ';
			}
			$str .= $business.')';
			
			mysql_query('insert into log (user, nickname, action, date, content, sqlStr) values("'.$_COOKIE['username'].'", "'.$_COOKIE['nickname'].'", "添加", "'.date("Y-m-d").'", \''.$str.'\', \''.$sql.'\')');
		}
	}

?>